using MicroMsg.Common.Utils;
using MicroMsg.UI.Page;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class AlbumDataControl : UserControl
	{
		private string[] EnglishMonth = new string[]
		{
			"Jan",
			"Feb",
			"Mar",
			"Apr",
			"May",
			"Jun",
			"Jul",
			"Aug",
			"Sep",
			"Oct",
			"Nov",
			"Dec"
		};
		private string[] ChineseMonth = new string[]
		{
			"1月",
			"2月",
			"3月",
			"4月",
			"5月",
			"6月",
			"7月",
			"8月",
			"9月",
			"10月",
			"11月",
			"12月"
		};
		internal StackPanel LayoutRoot;
		internal TextBlock DayBlock;
		internal TextBlock MonthBlock;
		internal TextBlock LocationBlock;
		private bool _contentLoaded;
		public AlbumDataControl()
		{
			this.InitializeComponent();
			this.DayBlock.set_Foreground(R.theme.SNS_USERPAGEITEM_DATA_BRUSH);
			this.MonthBlock.set_Foreground(R.theme.SNS_USERPAGEITEM_DATA_BRUSH);
			this.LocationBlock.set_Foreground(R.theme.SNS_USERPAGEITEM_LOCATION_BRUSH);
		}
		public void SetContent(SnsUserPageItemData item)
		{
			DateTime currentTime = DateTime.get_Now().ToLocalTime();
			DateTime yesterday = Util.SencondsToLocalTime((long)((ulong)item.nCreateTime));
			if (R.isChineseCN() && (yesterday.get_Ticks() > currentTime.get_Ticks() || (yesterday.get_Year() == currentTime.get_Year() && yesterday.get_Month() == currentTime.get_Month() && yesterday.get_Day() == currentTime.get_Day())))
			{
				this.DayBlock.set_Text("今天");
				this.MonthBlock.set_Visibility(1);
			}
			else
			{
				if (R.isChineseCN() && Util.isYesterday(currentTime, yesterday))
				{
					this.DayBlock.set_Text("昨天");
					this.MonthBlock.set_Visibility(1);
				}
				else
				{
					string text = yesterday.get_Day().ToString();
					if (text.get_Length() == 1)
					{
						text = "0" + text;
					}
					this.DayBlock.set_Text(text);
					if (R.isEnglish())
					{
						this.MonthBlock.set_Text(this.EnglishMonth[yesterday.get_Month() - 1]);
					}
					else
					{
						this.MonthBlock.set_Text(this.ChineseMonth[yesterday.get_Month() - 1]);
					}
					this.MonthBlock.set_Visibility(0);
				}
			}
			if (!string.IsNullOrEmpty(item.strLocation))
			{
				this.LocationBlock.set_Text(item.strLocation);
				this.LocationBlock.set_Visibility(0);
				return;
			}
			this.LocationBlock.set_Visibility(1);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Sns/Album/UI/AlbumDataControl.xaml", 2));
			this.LayoutRoot = (StackPanel)base.FindName("LayoutRoot");
			this.DayBlock = (TextBlock)base.FindName("DayBlock");
			this.MonthBlock = (TextBlock)base.FindName("MonthBlock");
			this.LocationBlock = (TextBlock)base.FindName("LocationBlock");
		}
	}
}
